package com.sbio.udiapp.adapter;

import android.view.View;
import android.widget.CheckedTextView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.sbio.udiapp.R;
import com.sbio.udiapp.listener.RawMaterialSubPackListAdapterListener;

public class ViewHolder2<T extends ListItemData> extends RecyclerView.ViewHolder {

    CheckedTextView tv;

    public ViewHolder2(@NonNull View itemView) {
        super(itemView);
        tv = itemView.findViewById(R.id.tv_box_code);
    }

    // 修改 bind 方法接收 ListItemData 类型
    public void bind(T data, RawMaterialSubPackListAdapterListener<T> listener, int position) {
        tv.setText(data.getDisplayText());
        tv.setOnClickListener(v -> listener.itemClick(data, position));
    }
}
